<template>
  <div class="routes">
    <div class="banner"></div>
    <!-- 面包屑导航 -->
    <breadcrumb></breadcrumb>
    <div class="route-details" v-for="item in list" :key="item.route_id">
      <div class="route-map">
        <img :src="require(`@/assets/images/${item.route_pic}`)" alt="">
      </div>
      <div class="route-intro">
        <div class="route-tit">
          <h5>{{ item.title }}</h5>
        </div>
        <div class="route-plan">
          <div class="range">
            <p>总路程约<span>
                {{ item.road.reduce((res,item)=> res+item.distance,0).toFixed(1) }}</span>km</p>
          </div>
          <div class="node-box">
            <template v-for="(roadItem) in item.road">
              <div class="node-place"><i class="iconfont icon-scenery"></i> {{ roadItem.name}}</div>
              <div class="drive-gap">
                <p v-show="roadItem.distance">约{{ roadItem.distance }}公里</p>
              </div>
            </template>
          </div>
          <div class="qr-code">
            <img :src="require(`@/assets/images/${item.qr_code}`)" alt="">
            <span>扫码手机查看</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: []
    }
  },
  created() {
    this.getRouteData()
  },

  methods: {
    getRouteData() {
      this.$axios
        .get('/data/route.json')
        .then((response) => {
          let { status, data } = response
          if (+status !== 200) return
          let rouId = this.$route.query.id
          this.list = data.filter((item) => {
            return item.route_id == rouId
          })
        })
        .catch((error) => {
          console.log(error)
        })
    }
  }
}
</script>

<style scoped>
.banner {
  width: 100%;
  height: 50vh;
  background: url(../assets/images/banner2.png) no-repeat;
  background-size: cover;
}
.routes {
  background: #f5f5f5;
  box-shadow: 2px 2px 3px #eeeeee;
  overflow: hidden;
}
.route-details {
  display: flex;
  justify-content: space-between;
  max-width: 1200px;
  margin: 50px auto;
  margin-bottom: 200px;
}
.route-map {
  width: 75%;
  border: 1px solid #e9e9e9;
  box-shadow: 2px 3px 5px #e2e2e2;
}
.route-map img {
  width: 100%;
}
.route-intro {
  position: relative;
  width: 24%;
  height: 600px;
  box-shadow: 2px 2px 3px #eeeeee;
  background: #fff;
}
.route-intro .route-tit {
  height: 120px;
  line-height: 120px;
  background: #b92f2f;
  border-radius: 5px 5px 0px 0px;
  text-align: center;
}
.route-intro .route-tit h5 {
  font-size: 20px;
  color: #f5f5f5;
  font-weight: normal;
}
.route-intro .route-plan {
  width: 100%;
  padding: 6px;
  margin-top: 3px;
}
.route-intro .route-plan .range {
  height: 40px;
  line-height: 40px;
  background: #b92f2f;
  padding: 0 10px;
  color: #f5f5f5;
}
.route-intro .route-plan .range p {
  position: relative;
}
.route-intro .route-plan .range p::after {
  content: '\e62e';
  font-family: 'iconfont';
  position: absolute;
  right: 0;
}
.route-intro .route-plan .range p span {
  display: inline-block;
  padding: 0 5px;
  font-size: 18px;
}
.route-intro .route-plan .node-box {
  background-color: #fcf1f1;
  padding: 1vw 1vw 5vw;
  font-size: 15px;
}
.route-intro .route-plan .node-box > div {
  line-height: 35px;
}
.route-intro .route-plan .node-box .node-place {
  color: #666;
}
.route-intro .route-plan .node-box .node-place i {
  color: #f5f5f5;
  background: #b92f2f;
  padding: 4px;
  border-radius: 50%;
  margin-right: 10px;
}
.route-intro .route-plan .node-box .drive-gap {
  margin-left: 10px;
  padding-left: 30px;
  border-left: 2px solid #b92f2f;
  color: #e25656;
}
.route-intro .route-plan .node-box .drive-gap p::before {
  content: '\ec6d';
  font-family: 'iconfont';
  font-size: 20px;
  padding-right: 10px;
}
.route-intro .route-plan .qr-code {
  width: 100px;
  height: 120px;
  position: absolute;
  right: 5px;
  bottom: 5px;
}
.route-intro .route-plan .qr-code img {
  width: 100%;
}
.route-intro .route-plan .qr-code span {
  display: block;
  padding: 3px 3px;
  background: #c73535;
  color: #f5f5f5;
  text-align: center;
  font-size: 12px;
}
.activeTab {
  color: #f5f5f5;
  background: brown;
}

/* 移动端样式 */
@media screen and (max-width: 767px) {
  .banner {
    display: none;
  }
  .route-details {
    margin: 0;
    padding-top: 10px;
    justify-content: initial;
    flex-direction: column-reverse;
  }
  .route-map {
    width: 97%;
    margin: 0 auto;
  }
  .route-intro {
    width: 97%;
    height: auto;
    margin: 0 auto;
  }
  .route-intro .route-tit {
    height: 10vw;
    line-height: 10vw;
  }
  .route-intro .route-tit h5 {
    font-size: 13rem;
  }
  .route-intro .route-plan .range {
    height: 7vw;
    line-height: 7vw;
  }
  .route-intro .route-plan .range p {
    font-size: 10rem;
  }
  .route-intro .route-plan .range p span {
    font-size: 13rem;
  }
  .route-intro .route-plan .node-box .node-place {
    font-size: 10rem;
  }
  .route-intro .route-plan .node-box > div {
    line-height: 7vw;
  }
  .route-intro .route-plan .node-box .drive-gap p {
    font-size: 10rem;
  }

  .route-intro .route-plan .qr-code {
    width: 15vw;
    height: 25vw;
  }
  .route-intro .route-plan .qr-code span {
    font-size: 8rem;
  }
}
</style>